﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects.DataClasses;

namespace GestionAutoEcoleModel
{
    public static class General
    {
        public static void AddRange<T>(this EntityCollection<T> destinationEntityCollection,
                                       EntityCollection<T> sourceEntityCollection) where T : class
        {
            var array = new T[sourceEntityCollection.Count()];

            sourceEntityCollection.CopyTo(array, 0);
            destinationEntityCollection.Clear();

            foreach (var entity in array)
            {
                destinationEntityCollection.Attach(entity);
            }
        }
    }
}
